home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6136 < prev    next >
Encoding:
Text File  |  1996-08-05  |  982 b   |  35 lines

  1. Newsgroups: comp.lang.c
  2. Path: netcom.com!timmyd
  3. From: timmyd@netcom.com (Tim DeBenedictis)
  4. Subject: Re: How do I use abs() on floats ?
  5. Message-ID: <timmydDn73Ct.C6r@netcom.com>
  6. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  7. X-Newsreader: TIN [version 1.2 PL1]
  8. References: <4ghki0$b44@LNCSEX0003.eu.btco.com>
  9. Date: Thu, 22 Feb 1996 20:53:16 GMT
  10. Sender: timmyd@netcom21.netcom.com
  11.  
  12. Use fabs() instead of abs().
  13.  
  14. -Tim DeBenedictis
  15. timmyd@netcom.com
  16.  
  17. PS You could always write your own FABS macro, too; might be faster than 
  18. fabs() but I doubt it:
  19.  
  20. #define FABS(x) (x>0.0?x:-x)
  21.  
  22.  
  23.  
  24.  
  25. DaveMx wrote:
  26. : What's the easiest way to get the absolute scalar value of a float.
  27. : I need to test to see of a variable is 'bigger' than a certain tolerance.
  28.  
  29. : e.g.
  30.  
  31. : if ( abs (error__float)  > MAX_TOLERANCE )   printf ( "Tolerance level exceeded \n" );
  32.  
  33.  
  34. : BUT the abs() function says it only works on int 's . Any ideas how to do it for floats in the most elegant way ???
  35.